package day3;

import java.util.Arrays;
import java.util.Scanner;

public class Solder {
	
	private Weapon[] repository;//武器仓库
	private int currentIndex;
	//当前使用武器
	private Weapon currentWeapon;
	
		public Solder(Weapon...ws) {
	/*	repository = new Weapon[3];
		repository[0] = w;
		repository[1] = w1;
		repository[2] = w2; */
			repository = ws;//通过可变参数初始化仓库
			currentWeapon = repository[currentIndex];
	}
	
	public void show() {
		System.out.println(Arrays.toString(repository));
	}
//当前武器攻击
	public void l() {
		currentWeapon.attack();
	}
	//切换武器  改变下标
	public void q() {
/*		currentIndex++;
		currentWeapon = repository[currentIndex];
		if(currentIndex == repository.length-1) {
			currentIndex = 0;    */ 
		currentIndex = (currentIndex+1)%3;
		//循环变动下标
		}
}
